<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>新增供应商信息</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/sources/css/style.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/sources/scripts/jquery-3.4.1.min.js"></script>
<!-- <script type="text/javascript">
		function addShop(){
			var shop_name=$("#shop_name").val();
			if(shop_name==""){
				alert("店铺名称不能为空");
				return;
			}
			//发送ajax请求
			var url="${pageContext.request.contextPath}/add_shop";//访问地址
			//var param=$("#form").serialize();//参数
			//alert(param)
			$.post(url,param,function(data){
				if(data=="1"){
					window.location.href="${pageContext.request.contextPath}/shop_list";
					return;
				}else{
					alert(data);
				}
			});
		}
</script> -->
<script type="text/javascript">
function addShop() {  
	var shop_name=$("#shop_name").val();
	if(shop_name==""){
		alert("店铺名称不能为空");
		return;
	}
     var formData = new FormData($("#form")[0]);  
     $.ajax({  
          url: '${pageContext.request.contextPath}/add_shop',  
          type: 'POST',  
          data: formData,  
          async: false,  
          cache: false,  
          contentType: false,  
          processData: false,  
          success: function(data) {
        	  if(data=="1"){
  				// 获得frame索引
  				alert("提交成功");
  				var index = parent.layer.getFrameIndex(window.name);
  				//关闭当前frame
  				parent.layer.close(index);
  				window.parent.location.reload();
  			}else{
  				alert(data);
  			}
          },  
          error: function(data) {     
          }  
     });  
}
</script>
<body>
	<!-- Table goes in the document BODY -->
	<form id="form" method="post" enctype="multipart/form-data">
		<table class="hovertable">
			<tr>
				<th colspan="2">新增店铺信息</th>
			</tr>
			<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
				<td>店铺名称</td><td><input id="shop_name" type="text" name="shop_name"></td>
			</tr>
			<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
				<td>店铺地址</td><td><input id="shop_address" type="text" name="shop_address"></td>
			</tr>
			<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
				<td>店铺类型</td><td><input type="text" name="shop_type"></td>
			</tr>
			<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
				<td>店铺头像</td><td><input type="file" name="file"></td>
			</tr>
			<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
				<td>店铺详情</td><td><input type="text" name="shop_desc"></td>
			</tr>
			 
			 <tr style="background-color:#ffffff;text-align:center">
				<td colspan="2"><input type="button" onclick="addShop()" value="提交" style="width:100%"></td>
			</tr>
		</table>
	</form>
</body>
</html>